package ve.gob.cne.action.login.interceptor;

import java.util.Map;

import ve.gob.cne.to.UsuarioTo;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class LoginInterceptor implements Interceptor {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public void destroy() {

	}
	
	@Override
	public void init() {

	}
	
	@Override
	public String intercept(ActionInvocation ai) throws Exception {
		Map session = ai.getInvocationContext().getSession();
        UsuarioTo usuario = (UsuarioTo) session.get("usuario");
        
        if(usuario == null){
            return Action.LOGIN;
        }else{
            return ai.invoke();
        }
	}
	
}
